import 'package:backend.core/core/domain/entities/api/app_store/api_app_store_transaction_revocation_info.dart';
import 'package:backend.core/core/domain/entities/app_store/app_store_transaction_revocation_info.dart';
import 'package:backend.purchases/domain/helpers/api/app_store/create_api_app_store_revocation_reason_from_internal_one.dart';

abstract class CreateApiAppStoreTransactionRevocationInfoFromInternalOne {
  ApiAppStoreTransactionRevocationInfo call({
    required AppStoreTransactionRevocationInfo revocationInfo,
  });
}

class CreateApiAppStoreTransactionRevocationInfoFromInternalOneImpl
    implements CreateApiAppStoreTransactionRevocationInfoFromInternalOne {
  const CreateApiAppStoreTransactionRevocationInfoFromInternalOneImpl({
    required CreateApiAppStoreTransactionRevocationReasonFromInternalOne
        createApiAppStoreTransactionRevocationReasonFromInternalOne,
  }) : _createApiAppStoreTransactionRevocationReasonFromInternalOne =
            createApiAppStoreTransactionRevocationReasonFromInternalOne;

  final CreateApiAppStoreTransactionRevocationReasonFromInternalOne
      _createApiAppStoreTransactionRevocationReasonFromInternalOne;

  @override
  ApiAppStoreTransactionRevocationInfo call({
    required AppStoreTransactionRevocationInfo revocationInfo,
  }) {
    final apiRevocationReason = _createApiAppStoreTransactionRevocationReasonFromInternalOne(
      revocationReason: revocationInfo.reason,
    );

    return ApiAppStoreTransactionRevocationInfo(
      reason: apiRevocationReason,
      time: revocationInfo.time,
    );
  }
}
